<template>
<view class="tui-cards-container" v-if="display">
  <view class="service-evaluation">
    <view class="header">
      <label class="header-label">赠送权益</label>
      <view class="btn-close" @tap="handleClose">关闭</view>
    </view>
    <view class="main">
		每次赠送消耗权益 x1
      <!-- <view class="main-evaluation-score">
        <image v-for="(item, index) in scoreList" :key="index" class="score-star" :data-score="item" :src="'/static/static/images/star' + (item > score ? '-grey': '') + '.png'" @tap="handleScore"></image>
      </view> -->
    </view>
    <view class="footer">
      <view class="btn" @tap="sendMessage" :disabled="score===0 && !comment">立即赠送</view>
    </view>
  </view>
</view>
</template>

<script>
import {sendRights} from "@/common/config/chat.js"

export default {
  data() {
    return {
		num:1
    };
  },

  components: {},
  // #ifdef APP-PLUS
  props:['display','conversation'],
  // #endif
  // #ifdef MP-WEIXIN
  props: {
    display: {
      type: Boolean,
      default: ''
    },
  	conversation: {
  	  type: Object,
  	  default: () => {}
  	}
  },
  // #endif
  
  watch: {
	  // #ifdef APP-PLUS
	  conversation(e){
		  this.conversation=e
	  },
	  // #endif
	  // #ifdef MP-WEIXIN
	  display: {
	    handler: function (newVal) {
	    },
	    immediate: true,
	    deep:true
	  },
	  conversation: {
	    handler: function (newVal) {
	  	  console.log(99999999,newVal)
	      // todo 值会被改变
	      this.setData({
	        conversation: newVal
	      });
	    },
	    immediate: true,
	    deep: true
	  }
	  // #endif
	  
    
  },

  onPageShow() {
	  console.log(111111111111111,this.conversation)
	// this.$on('handlePresent', function(res){
	// 	console.log(090900,res)
	// });
  },

  methods: {
    handleClose() {
      this.$emit('close', {
        detail: {
          key: '3'
        }
      });
    },
    sendMessage() {
		// sendRights(uid=0).then(res=>{
		// 	console.log('赠送权益',res)
		// })
		console.log(111111111111111,this.conversation)
      this.$emit('sendCustomMessage', {
        detail: {
			payload: {
			  // data 字段作为表示，可以自定义
			  data: 'present',
			  description: '赠送礼物',
			  // 获取骰子点数
			  extension: JSON.stringify({
			    num: 1,
				userID:this.conversation.userProfile.userID
			  })
			}
        }
      });
      this.setData({
        score: 0,
        comment: ''
      });
      this.handleClose();
    },
  }
};
</script>
<style>
@import "./index.css";
</style>
